<?php
$username = $_REQUEST['username'];
$password = $_POST['password'];

//包含数据库连接的文件
require_once("../system/conndb.php");
//获取数据库连接，connect 在 dbconn文件中定义
$link = connect();

//查询数据库
$sql = "select * from users 
       where uname='".$username."' and password='".$password."'";
//echo $sql;

$result = mysqli_query($link,
      $sql);
//var_dump($result);
// 获取数据 
if(mysqli_num_rows($result)==0)
	echo '用户名或密码错误';
else{
	$data = mysqli_fetch_all(
    $result,MYSQLI_ASSOC); 
	session_start();
	$_SESSION['user']= $data[0];
	//$_SESSION['uid']= $data[0]['uid'];

	//echo '<a href="userlist.php">用户管理</a>';
	echo "登录成功！2秒后自动跳转！";
	header("Refresh:2;url=pindex.php");
}

?>